package com.keller.retrofitdemo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import com.keller.retrofitdemo.retrofitutils.ApiService;
import com.keller.retrofitdemo.retrofitutils.Retrofit2Util;
import com.keller.retrofitdemo.retrofitutils.bean.PictureBean;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class MainActivity extends AppCompatActivity {

    public static final String TAG = "kellerTest";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void get(View view) {
        Log.d(TAG, "get");
        ApiService apiService = Retrofit2Util.getRetrofit(this, ApiService.PICTURE_ROOT_URL).create(ApiService.class);
        Call<PictureBean> pictureBeanList = apiService.getPictureBeanList("5");
        pictureBeanList.enqueue(new Callback<PictureBean>() {
            @Override
            public void onResponse(Call<PictureBean> call, Response<PictureBean> response) {
                Log.d(TAG, response.toString());

                //请求成功
            }

            @Override
            public void onFailure(Call<PictureBean> call, Throwable t) {
//请求失败
            }
        });

    }
}
